package main

import (
	"google.golang.org/grpc"
	"grpc-comment/configs"
	"grpc-comment/initialize"
	"grpc-comment/protos/comment"
	"grpc-comment/protos/goods"
	"grpc-comment/services"
	"log"
	"net"
)

func main(){
	//获得配置对象
	Yaml := configs.InitConfig()
	initialize.Init(Yaml)
	//grpc服务监听方式
	//rpcServer := grpc.NewServer(grpc.Creds(helper.GetServerCreds()))
	rpcServer := grpc.NewServer()
	//注册商品服务
	goods.RegisterGoodsServiceServer(rpcServer,new(services.GoodsService))
	//注册评论服务
	//comment.RegisterCommentServiceServer(rpcServer,new(services.CommentService)) //普通写法
	comment.RegisterCommentServiceServer(rpcServer,services.NewCommentService()) //封装写法
	//rpc服务监听方式
	lis, err := net.Listen("tcp",*configs.EnvPort)
	if err != nil {
		log.Fatal(err)
	}else {
		log.Println("grpc服务开启成功 ,address:127.0.0.1"+*configs.EnvPort)
	}
	rpcServer.Serve(lis)

}
